<template>
	<view class="bigbox">
		<view class="topbox">
			<view class="inputbox">
				<image src="https://fangguaner.wm76.mtnet.ren/static/applet/sousuo.png" mode=""></image>
				<input type="text" value="" placeholder="请输入你搜索的内容" @input="plotname" />
			</view>
		</view>

		<view class="boxes" v-for="(item,index) in arr" :key="index" @click="xiangqing(item)">
			<text class="name">{{item.contact}}</text>
			<text class="telephone">{{item.contact_number}}</text>
			<text class="lock" @click.stop="lock(item.id)">锁定</text>
		</view>
	</view>
</template>

<script>
	import {
		getpublicpassenger,
		lockpassenger
	} from "../../api/api/index"
	export default {
		data() {
			return {
				arr: [],
				page: 0,
				limit: 20,
				isOk: false,
				time: 0,
			}
		},
		methods: {
			plotname(e) {
				let data = {
					search: e.detail.value
				}
				if(e.detail.value==""){
					this.arr=[]
					this.page=0
					this.isOk=false
					this.public()
					return
				}else{
					uni.showLoading({
						mask: true,
						title: '加载中'
					})
					getpublicpassenger(data).then(res => {
						uni.hideLoading()
						this.arr = res.data
					})
				}
			},
			public() {
				if (this.isOk) {
					return uni.showToast({
						icon: 'none',
						title: '没有更多了'
					})
				}
				uni.showLoading({
					mask: true,
					title: '加载中'
				})
				this.page++
				let data = {
					page: this.page,
					limit: this.limit
				}
				getpublicpassenger(data).then(res => {
					uni.hideLoading()
					this.arr = this.arr.concat(res.data)
					if (res.data.length < this.limit) {
						this.isOk = true
					}
				})
			},
			lock(id) {
				lockpassenger({
					id: id
				}).then(res => {
					uni.showToast({
						title: res.message,
						icon: "none",
						duration: 1500
					})
					setTimeout(function() {
						uni.reLaunch({
							url: "../Sourceofcustomers/index"
						})
					}, 1500)
				})
			},
			xiangqing(item) {
				this.jumpLink({
					link: "/pages/pondparticulars/index",
					query: {
						id: item.id,
						clientname: item.contact,
						contact_number: item.contact_number
					}
				})
			}
		},
		onLoad() {},
		onReachBottom() {
			this.public()
		},
		onShow() {
			this.arr = []
			this.page = 0
			this.isOk = false
			this.public()
		}
	}
</script>

<style scoped lang="less">
	.bigbox {
		background-color: #EDEDED;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		padding: 20rpx;
		box-sizing: border-box;
		overflow: scroll;

		.topbox {
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;

			.inputbox {
				height: 80rpx;
				width: 100%;
				background-color: #FFFFFF;
				border-radius: 10rpx;
				display: flex;

				image {
					width: 35rpx;
					height: 35rpx;
					margin-top: 25rpx;
					margin-left: 25rpx;
				}

				input {
					width: 610rpx;
					margin-top: 16rpx;
					font-size: 24rpx;
					margin-left: 22rpx;
				}
			}
		}

		.boxes {
			width: 100%;
			height: 160rpx;
			background-color: #ffffff;
			border-radius: 10rpx;
			line-height: 160rpx;
			padding: 0 30rpx;
			box-sizing: border-box;
			margin-bottom: 30rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.name {
				font-family: MicrosoftYaHei-Bold;
				font-size: 30rpx;
				letter-spacing: 0rpx;
				color: #000000;
				font-weight: 700;
				margin-right: 40rpx;
			}

			.telephone {
				color: #666666;
				font-family: PingFang-SC-Heavy;
				font-size: 24rpx;
				margin-right: 40rpx;
			}

			.indetiy {
				display: inline-block;
				width: 79rpx;
				height: 33rpx;
				background-color: #ffcc00;
				border-radius: 17rpx;
				line-height: 33rpx;
				text-align: center;
				color: #993300;
				font-size: 22rpx;
				font-family: MicrosoftYaHei;
				margin-right: 40rpx;
			}

			.lock {
				display: inline-block;
				width: 174rpx;
				height: 61rpx;
				background-color: #ffffff;
				border-radius: 31rpx;
				border: solid 3rpx #df4744;
				line-height: 61rpx;
				text-align: center;
				font-family: MicrosoftYaHei;
				font-size: 30rpx;
				color: #d72f2c;
				margin-left: 90rpx;
			}
		}
	}
</style>
